<template>
  <div v-loading="pageLoading" style="padding-left:24px">
    <el-input v-model="chaxun" size="medium" style="margin-bottom:20px;width:192px" placeholder="输入姓名进行搜索" clearable @input="onCheck" />
    <el-button type="primary" style="margin-left:12px;" size="small" @click="check">查询</el-button>
    <div class="tab">
      <el-table :data="tableData" style="border-radio:10px" cell-style="cursor:pointer" @row-click="checkGlory">
        <el-table-column label="排名" width="80px" align="center">
          <template slot-scope="{row}">
            <span :class="'ditu'+row.finalRank" class="ditu">{{ row.finalRank }}</span>
          </template>
        </el-table-column>
        <el-table-column label="姓名" width="140px">
          <template slot-scope="{row}">
            <div class="img_cell">
              <img class="roodsPhoto" :src="getStaticFileUrl(row.photoUrl)" alt="">
              <div class="table_name">{{ row.name }}</div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="性别" align="center">
          <template slot-scope="{row}">
            {{ row.gender }}
          </template>
        </el-table-column>
        <el-table-column label="金牌" align="center">
          <template slot-scope="{row}">
            {{ row.goldCount }}
          </template>
        </el-table-column>
        <el-table-column label="银牌" align="center">
          <template slot-scope="{row}">
            {{ row.silverCount }}
          </template>
        </el-table-column>
        <el-table-column label="铜牌" align="center">
          <template slot-scope="{row}">
            {{ row.bronzeCount }}
          </template>
        </el-table-column>
        <el-table-column label="战绩" align="center">
          <template slot-scope="{row}">
            <span style="color:#de1c1c;font-weight: 600">{{ row.winCount !== null && row.winCount !== undefined ? row.winCount + '/': 0 + '/' }}</span><span style="color: #989898;font-weight: 600">{{ row.loseCount !== null && row.loseCount !== undefined ? row.loseCount : 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="胜率" align="center">
          <template slot-scope="{row}">
            <span style="color:#de1c1c;font-weight: 600">{{ row.winPercent !== null && row.winPercent !== undefined ? (row.winPercent) % 1 === 0 ? (row.winPercent * 100) + '%' : (row.winPercent * 100).toFixed(2) + '%' : '--' }}</span>
          </template>
        </el-table-column>
        <el-table-column label="个人积分" align="center">
          <template slot-scope="{row}">
            {{ row.finalPoints }}
          </template>
        </el-table-column>
      </el-table>
      <!-- <img v-if="isShowImg && getStaticFileUrl(bigImg)" class="roodsBigPhoto" :style="position" :src="getStaticFileUrl(bigImg)" alt="" @error="errorPhoto"> -->
    </div>
    <el-row class="gl_pt_20" style="text-align: right;">
      <el-pagination
        :current-page="Api_GET_EventsManagementEventResultPlatformPointRankListQO.Page"
        :page-size="Api_GET_EventsManagementEventResultPlatformPointRankListQO.MaxResultCount"
        :total="total"
        layout="total,sizes,prev,pager,next,jumper"
        :page-sizes="[10, 20, 30, 40]"
        @size-change="sizeChange"
        @current-change="pageIndexChange"
      />
    </el-row>
  </div>
</template>
<script>
import { Api_GET_EventsManagementEventResultPlatformPointRankListQO } from '@/lib/form/game/swaggerForm';
import { api_GET_EventsManagementEventResultPlatformPointRankList } from '@/extend/api/gameswaggerApi/app';
import defaultImg from '@/assets/images/face_default.png';
export default {
  props: {
    active: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      pageLoading: false,
      defaultImg: defaultImg,
      chaxun: '',
      Api_GET_EventsManagementEventResultPlatformPointRankListQO: new Api_GET_EventsManagementEventResultPlatformPointRankListQO(),
      tableData: [],
      total: 0,
      isShowImg: false,
      position: {
        left: 0,
        top: 0
      },
      bigImg: ''
    };
  },
  created() {
    this.getListData();
  },
  methods: {
    // 获取积分列表
    getListData(page) {
      this.pageLoading = true;
      this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.Page = page || 1;
      this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.DelegationId = this.$route.query.gid;
      this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.Type = 'DelegationRegister';
      this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.Sorting = null;
      this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.SkipCount = (this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.Page - 1) * this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.MaxResultCount;
      api_GET_EventsManagementEventResultPlatformPointRankList(this.Api_GET_EventsManagementEventResultPlatformPointRankListQO).then((res) => {
        console.log(res);
        this.tableData = res.items;
        this.total = res.totalCount;
        this.pageLoading = false;
      }, error => {
        this.loading = false;
        const _msg = error.error.message || error.message;
        this.$message({ type: 'error', message: _msg });
      });
    },
    // 获取静态文件
    getStaticFileUrl(relativeUrl) {
      if (relativeUrl) {
        return WEB_CONFIG.VUE_APP_STATIC_FILE_RUL + relativeUrl;
      } else {
        return require('@/assets/images/face_default.png');
      }
    },
    // errorPhoto() {
    //   const img = event.srcElement;
    //   img.src = this.defaultImg;
    // },
    // showGoodsImg(event, img) {
    //   const _this = this;
    //   _this.bigImg = img;
    //   const _img = event.target;
    //   const _position = _img.getBoundingClientRect();
    //   this.timeOut = setTimeout(() => {
    //     _this.isShowImg = true;
    //     _this.$set(_this.position, 'left', _position.left + 60 + 'px');
    //     _this.$set(_this.position, 'top', _position.top + 'px');
    //   }, 300);
    // },
    // hideGoodsImg() {
    //   const _this = this;
    //   clearTimeout(this.timeOut);
    //   _this.isShowImg = false;
    // },
    sizeChange(MaxResultCount) {
      this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.MaxResultCount = MaxResultCount;
      this.getListData();
    },
    pageIndexChange(currentPage) {
      this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.Page = currentPage;
      this.getListData(currentPage);
    },
    // 查询
    check() {
      this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.Keyword = this.chaxun;
      this.getListData();
    },
    checkGlory(row) {
      this.$router.push({ 'name': 'PersonalType', 'query': { 'pid': row.entityId }});
    },
    onCheck() {
      this.Api_GET_EventsManagementEventResultPlatformPointRankListQO.Keyword = this.chaxun;
      this.getListData();
    }
  }
};
</script>
<style lang="scss" scoped>
.tab{
    border-radius: 15px;
    overflow: hidden;
    box-shadow:0px 0px 15px #e0dada;
    padding-top: 20px;
    padding-left: 12px;
    padding-right: 12px;
}
.ditu{
    display: inline-block;
    height: 36px;
    text-align: center;
    line-height: 36px;
    font-size: 20px;
    font-weight: 700;
}
.ditu1{
    background-image:url(../../assets/images/league/rank_1.png);
    background-size: 103%;
    color: white;
    width: 31px;
}
.ditu2{
    background-image:url(../../assets/images/league/rank_2.png);
    background-size: 103%;
    color: white;
    width: 31px;
}
.ditu3{
    background-image:url(../../assets/images/league/rank_3.png);
    background-size: 103%;
    color: white;
    width: 31px;
}
.roodsPhoto{
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 0px;
    margin-right: 10px;
  }
//去掉表格竖线
 ::v-deep .el-table_header td, ::v-deep .el-table td, ::v-deep .el-table th{
    border-right: 0px;
}
 ::v-deep .el-table{
    border: 0px;
    border-right: 0px !important;
    border-radius: 10px;
}
 ::v-deep .el-input--medium .el-input__inner{
  height: 32px;
}
.roodsBigPhoto {
  width: 30px;
  height: 30px;
  position: fixed;
  z-index: 10;
  border-radius: 50%;
}
.img_cell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}
.table_name {
  line-height: 48px;
}
</style>
